function sortDOM1 () {
var list = document.getElementById('test-list');
var arr = [].slice.call(document.getElementsByClassName("lang"));
arr.sort(function(x1,x2){
if (x1.innerHTML < x2.innerHTML){
return -1;
}else if (x1.innerHTML > x2.innerHTML){
return 1;
}else{
return 0;
}
});
for(var i = 0 ; i < arr.length ; i++){
list.appendChild(arr[i]);
}
}
function sortDOM2(){
var list = document.getElementById("test-list");
var lang = document.getElementsByClassName("lang");
var arrList = [];
for (var i = 0 ; i < lang.length ; i ++){
arrList[i] = lang[i].innerHTML;
}
arrList.sort();
list.innerHTML = "";
for (var i = 0 ; i < arrList.length ; i ++){
var newElement = document.createElement("li");
newElement.setAttribute("class","lang");
newElement.innerHTML = arrList[i];
list.appendChild(newElement);
}
}
function sortDOM3(){
var list = document.getElementById("test-list");
var lang = document.getElementsByClassName("lang");
var arrList2 = [];
for (var i = 0 ; i < lang.length ; i ++){
arrList2[i] = lang[i].innerHTML;
}
arrList2.sort();
for(var i = 0 ; i < arrList2.length ; i ++){
list.children[i].innerHTML = arrList2[i];
}
}
function sortDOM4 () {
var list = document.getElementById("test-list");
var lang = document.getElementsByClassName("lang");
for (var i = 0 ; i < lang.length-1 ; i++){
for(var j = i+1 ; j < lang.length ; j ++){
if (lang[i].innerHTML < lang[j].innerHTML){
var a ;
a = lang[i].innerHTML;
lang[i].innerHTML = lang[j].innerHTML;
lang[j].innerHTML = a;
}
}
list.children[i].innerHTML = lang[i].innerHTML;
}
}
function sortDOM5 (){
var list = document.getElementById("test-list");
var lang = document.getElementsByClassName("lang");
for (var i = 0 ; i < lang.length ; i ++){
for(var j = 0 ; j < lang.length - i -1 ; j ++){
if(lang[j].innerHTML > lang[j+1].innerHTML){
list.insertBefore(lang[j+1],lang[j]);
}
}
}
}